<!-- script for ckeditor -->
<script type="text/javascript" src="{$base_media}/ckeditor/ckeditor.js"></script>
<script type="text/javascript" src="{$base_media}/ckeditor/ckfinder/ckfinder.js"></script>
<!-- end script for ckeditor -->
<script type="text/javascript" charset="utf-8">
        // tabbed forms box
        $(function () {ldelim}
            var tabContainers = $('div#forms > div.innerContent'); // change div#forms to your new div id (example:div#pages) if you want to use tabs on another page or div.
            tabContainers.hide().filter(':first').show();

            $('ul.switcherTabs a').click(function () {ldelim}
                tabContainers.hide();
                tabContainers.filter(this.hash).show();
                $('ul.switcherTabs li').removeClass('selected');
                $(this).parent().addClass('selected');
                return false;
            {rdelim}).filter(':first').click();
        {rdelim});

        function checkForm()
        {ldelim}
			var service = jQuery.trim($('#category_id').val());
			if (isNaN(service) || service <= 0) {ldelim}
				alert('Bạn chưa chọn Loại Dịch vụ');
				$('#category').focus();
				return false;
			{rdelim}
            if (jQuery.trim($(":text").val()) == '') {ldelim}
                alert('Bạn chưa nhập Tiêu đề Dịch vụ');
                return false;
            {rdelim}
            var banner = $('#service_img').val();
            if (banner != '') {ldelim}
                var ext = banner.substring(banner.lastIndexOf('.'));
                if (!(ext && /^(.jpg|.JPG)$/i.test(ext))) {ldelim}
                    alert('File ảnh được định dạng .jpg !');
                    return false;
                {rdelim}
                if (findSize() == false ) {ldelim}
                    return false;
                {rdelim}
            {rdelim}
            return true;
        {rdelim}

        function executeCancel()
        {ldelim}
            window.history.back(-1);
        {rdelim}
        /**
         * changeCategory
         */
		function changeCategory(val)
		{ldelim}
			if (isNaN(val) || val <= 0) {ldelim}
				alert('Bạn chưa chọn Danh mục Bản tin');
				return false;
			{rdelim}
			$('#category_id').val(val);
		{rdelim}
        /**
         * findSize
         */
        function findSize()
        {ldelim}
            if ( $.browser.msie ) {ldelim}
               var a = document.getElementById('service_img').value;
                $('#myImage').attr('src',a);
                var imgbytes = document.getElementById('myImage').fileSize;
                var imgkbytes = Math.round(parseInt(imgbytes)/1024);
                if (imgkbytes > 40) {ldelim}
                    alert('Dung lượng file không được quá 40KB');
                    return false;
                {rdelim}
                //alert(imgkbytes+' KB');
            {rdelim} else {ldelim}
                var fileInput = $("#service_img")[0];
                var imgbytes = fileInput.files[0].fileSize; // Size returned in bytes.
                var imgkbytes = Math.round(parseInt(imgbytes)/1024);
                if (imgkbytes > 40) {ldelim}
                    alert('Dung lượng file không được quá 40KB');
                    return false;
                {rdelim}
                //alert(imgkbytes+' KB');
            {rdelim}
            return true;
        {rdelim}
</script>

<div id="leftBox">
{if $msgBoxDisp != ''}
<div class="{$clsType}Box" style="display:{$msgBoxDisp}">
  <div class="{$clsType}BoxTop">&nbsp;</div>
      {foreach from=$messages item=arrMsg}
        {foreach from=$arrMsg item=msg}
        <div class="msgBoxContent {$clsIcon}">
          <p>{$msg}</p>
          </div>
      {/foreach}
    {/foreach}
</div>
{/if}
<form id="mainForm" name="mainForm" method="post" action="{$actionForm}" enctype="multipart/form-data">
<div class="contentBox" id="forms">
  <div class="contentBoxTop">
    <h3>##TEM_ADD_EDIT## Dịch vụ</h3>
    <ul class="switcherTabs">
    {foreach item=arrLang from=$langList}
        {if $arrLang.default eq 1}
          <li class="selected"><a href="#box-{$arrLang.id}">{$arrLang.name}</a></li>
      {else}
          <li><a href="#box-{$arrLang.id}">{$arrLang.name}</a></li>
      {/if}
    {/foreach}
    </ul>
  </div>
	<div style="padding-left:12px;">
		<p>
			<select name="category" id="category" onchange="changeCategory(this.value)">
				<option value="">Loại Dịch vụ</option>
				{$categoryList}
			</select>
		</p>
		<p><label for="service_command"><input type="checkbox" name="service_command" id="service_command" value="Y" {if $service_command == 'Y'}checked{/if}>&nbsp;Bản tin cho phép bình luận</label></p>
        <p class="classname">
            <label for="service_show"><input type="checkbox" name="service_show" id="service_show" value="Y" {if $service_show == 'Y'}checked{/if}>&nbsp;Hiển thị bản tin</label>
        </p>
        <p class="classname">
            <label for="service_focus"><input type="checkbox" name="service_focus" id="service_focus" value="Y" {if $service_focus == 'Y'}checked{/if}>&nbsp;Dịch vụ Tiêu biểu</label>
        </p>
        <p><strong>##NEWS_POST_FILE_FIELD_TITLE_7##</strong> <em>(Kích thưước file : 215px × 140px. File định dạng .jpg)</em><br>
        {if $service_img != ''}<img src="{$imgAppPath}{$service_img}" border="0">{/if}
        <br>
        <label>
        <input type="file" name="service_img" id="service_img" value="">
        </label>
        </p>
	</div>
  {foreach item=arrLang from=$langList}
      <div class="innerContent" id="box-{$arrLang.id}">

          <p><strong>##SERVICES_POST_TEXT_FIELD_TITLE_4##</strong><br>
<label class="mediumInput">
<input type="text" name="service_title[{$arrLang.id}]" id="service_title{$arrLang.id}" value="{$arrLang.serviceObj->service_title|escape}" size="51">
</label>
</p><p><strong>##SERVICES_POST_TEXTAREA_FIELD_TITLE_5##</strong><br>
<label>
<textarea name="service_desc[{$arrLang.id}]" id="service_desc{$arrLang.id}">{$arrLang.serviceObj->service_desc|escape}</textarea>
</label>
</p><p><strong>##SERVICES_POST_TEXTAREA_FIELD_TITLE_6##</strong><br>
<label>
<textarea name="service_detail[{$arrLang.id}]" id="service_detail{$arrLang.id}">{$arrLang.serviceObj->service_detail|escape}</textarea>
</label>
</p>

          <p>
            <input name="" type="image" src="{$base_media}/images/bt_submit.gif" onclick="return checkForm();" />
          </p>

      </div>
  {/foreach}

</div>
<img id="myImage" src="" style="display:none;">
<input type="hidden" name="service_id" id="service_id" value="{$service_id}"/>
<input type="hidden" name="category_id" id="category_id" value="{$category_id}"/>
</form>
</div>
<script type="text/javascript" charset="utf-8">
    {foreach item=arrLang from=$langList}
        /* For textarea service_desc */
        var intro = CKEDITOR.replace('service_desc{$arrLang.id}', {ldelim}
					toolbar : [
								['Source', '-','Bold', 'Italic','Underline', 'Strike', '-',
								 'JustifyLeft', 'JustifyCenter', 'JustifyRight', 'JustifyBlock', '-',
								 'NumberedList','BulletedList', '-',
								 'Undo', 'Redo', '-',
								 'Link','Unlink','-',
								 'Font'
								]
							  ]
					{rdelim});
        //CKFinder.SetupCKEditor( intro ) ;
    {/foreach}
    {foreach item=arrLang from=$langList}
        /* For textarea service_detail */
        var intro = CKEDITOR.replace('service_detail{$arrLang.id}', {ldelim}
        			filebrowserBrowseUrl : '{$base_media}/ckeditor/ckfinder/ckfinder.html',
        			filebrowserImageBrowseUrl : '{$base_media}/ckeditor/ckfinder/ckfinder.html?type=Images',
        			filebrowserFlashBrowseUrl : '{$base_media}/ckeditor/ckfinder/ckfinder.html?type=Flash',
        			filebrowserUploadUrl : '{$base_media}/ckeditor/ckfinder/core/connector/php/connector.php?command=QuickUpload&type=Files',
        			filebrowserImageUploadUrl : '{$base_media}/ckeditor/ckfinder/core/connector/php/connector.php?command=QuickUpload&type=Images',
        			filebrowserFlashUploadUrl : '{$base_media}/ckeditor/ckfinder/core/connector/php/connector.php?command=QuickUpload&type=Flash',
					toolbar : [
								['Source', '-','Bold', 'Italic','Underline', 'Strike', '-',
								 'JustifyLeft', 'JustifyCenter', 'JustifyRight', 'JustifyBlock', '-',
								 'NumberedList','BulletedList', '-',
								 'Image','Table','HorizontalRule','-',
								 'Undo', 'Redo', '-',
								 'Link','Unlink','-',
								 'Font'
								]
							  ]
					{rdelim});
        //CKFinder.SetupCKEditor( intro ) ;
    {/foreach}

</script>
<div id="sidebar" class="rightBoxes">
  <div class="rightBoxesTop">
    <h3>##LIST_FUNC##</h3>
  </div>
  <div class="rightContent">
    <ul id="sidebarLinks">
      <li><a href="javascript:void(0);" onclick="javascript:executeCancel()">##SUBMIT_CANCEL##</a></li>
    </ul>
  </div>
</div>
<!-- end of #sidebar -->